<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>选购教材</title>

  <!-- 使用 Thymeleaf 引入 head.jsp -->
  <th:block th:insert="~{/head :: head}"></th:block>

  <script type="text/javascript">
    function checkAll(obj){
      // 获取复选框对象
      var boxs = document.getElementsByName("ids");
      for(var i = 0; i < boxs.length; i++){
        // 循环设置第 i 个复选框被选中
        boxs[i].checked = obj.checked;
      }
    }
  </script>
</head>
<body>
<div th:insert="~{header::header}"></div>
<div id="main">
  <!-- Start: Sidebar -->
  <div th:insert="~{student/left::aside}"></div>

  <!-- Start: Content -->
  <section id="content">
    <div id="topbar" class="affix">
      <ol class="breadcrumb">
        <li><a th:href="@{/admin/admin}"><span class="glyphicon glyphicon-home"></span></a></li>
        <li class="active">教材管理</li>
      </ol>
    </div>
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          <div class="panel">
            <div class="panel-heading">
              <div class="panel-title">教材列表</div>
              <form th:action="@{/student/findBookName}">
                <input type="text" name="bookName" value="请输入教材名">
                <div class="pull-left">
                  <button type="submit" class="btn btn-default btn-gradient pull-right delall">
                    查找
                  </button>
                </div>
              </form>
            </div>
            <form th:action="@{/student/addOrders}" method="post">
              <input type="hidden" name="studentId" th:value="${student.studentId}">
              <div class="panel-body">
                <table class="table table-striped table-bordered table-hover dataTable">
                  <tr class="active">
                    <th class="text-center">
                      <input class="btn btn-gray btn-sm" id="selectAll" type="checkbox" onclick="checkAll(this)" />全选
                    </th>
                    <th>序号</th>
                    <th>教材ID</th>
                    <th>书名</th>
                    <th>课程名称</th>
                    <th>作者</th>
                    <th>ISBN</th>
                    <th>价格</th>
                    <th>出版日期</th>
                    <th>版本</th>
                  </tr>

                  <!-- Thymeleaf 循环替代 c:forEach -->
                  <tr th:each="m,s: ${textbooks}">
                    <td class="text-center">
                      <input type="checkbox" name="ids" class="cbox" th:value="${m.textbookId}" />
                    </td>
                    <td th:text="${s.index + 1}"></td>
                    <td><a th:href="@{/admin/findTextbookById/{textbookId}(textbookId=${m.textbookId})}" th:text="${m.textbookId}"></a></td>
                    <td th:text="${m.bookName}"></td>
                    <td th:text="${m.courseName}"></td>
                    <td th:text="${m.author}"></td>
                    <td th:text="${m.ISBN}"></td>
                    <td th:text="${m.price}"></td>
                    <td th:text="${m.publishDate}"></td>
                    <td th:text="${m.version}"></td>


                  </tr>
                </table>

                <button type="submit" >加入购物车</button>


              </div>

            </form>
          </div>
        </div>
      </div>
    </div>
  </section>
  <!-- End: Content -->
</div>
</body>
</html>